#!/bin/bash

# Get rid of old tarfile
rm -f dr-deps.tar.bz2

# Freetype2
cd freetype
git pull
cd ..

# JBIG2dec
cd jbig2dec
git pull
cd ..

# IJG JPEG
# just download from www.ijg.org (version 8c, 16 Jan 2011)

# OpenJPEG
cd openjpeg
svn up
cd ..

# muPDF
cd mupdf
darcs pull
cd ..

# Create tarfile
tar --exclude-backups --exclude-vcs -cjf dr-deps.tar.bz2 freetype jbig2dec jpeg mupdf openjpeg/libopenjpeg

# Update the droidreader directories, if a destination was entered
if [ "$1" != '' ]; then
   rm -rf $1/jni/freetype
   rm -rf $1/jni/jbig2dec
   rm -rf $1/jni/jpeg
   rm -rf $1/jni/openjpeg
   rm -rf $1/jni/mupdf
   tar -C $1/jni -xjf dr-deps.tar.bz2
fi
